package com.example.demo.controller;

import com.example.demo.entity.Announcement;
import com.example.demo.service.AnnouncementService;
import com.example.demo.service.impl.AnnouncementServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/app/announcements")
public class AnnouncementController {

    private final AnnouncementService announcementService;

    @Autowired
    public AnnouncementController(AnnouncementServiceImpl announcementServiceImpl) {
        this.announcementService = announcementServiceImpl;
    }

    @GetMapping("/get/list")
    public List<Announcement> getAll() {
        System.out.println("调用了List<Announcement> getAll()");
        return announcementService.findAll();
    }
}
